#include <iostream>
#include <string>

using namespace std;

bool prostoe(int k) {
	for (int y = 2; y <= int(sqrt(k)); y++) {
		if (k % y == 0) {
			return true;
		}
	}
	return false;
}

int main()
{
    string line, word="", s="";
	bool d = true;
	

    getline(cin, line);
	line += ' ';
    for (char ch : line)
    {
		if (ch == ' ') {
			if (word == "one") {
				s += "1";
			}
			else if (word == "two") {
				s += "2";
			}
			else if (word == "three") {
				s += "3";
			}
			else if (word == "four") {
				s += "4";
			}
			else if (word == "five") {
				s += "5";
			}
			else if (word == "six") {
				s += "6";
			}
			else if (word == "seven") {
				s += "7";
			}
			else if (word == "eight") {
				s += "8";
			}
			else if (word == "nine") {
				s += "9";
			}
			else if (word == "zero") {
				s += "0";
			}
			else d = false;
			word.clear();
		}
		else {
			word += ch;

		}
		

    }
	if (s.length() != 3 or d == false) cout << "Wrong input";
	else {
		int n = stoi(s), plus = stoi(s), minus = stoi(s);
		while (prostoe(plus)) {
			plus++;
		}
		while (prostoe(minus)) {
			minus--;
		}

		if (plus - n >= n - minus)
			s = to_string(minus);
		else s = to_string(plus);

		if (s.length() == 1) {
			s = '0' + s;
			s = '0' + s;
		}
		else if (s.length() == 2) {
			s = '0' + s;
			
		}
		cout << s;
	}

}
